//
//  WXPAuthKTPContentView.m
//  MexicoLoan
//
//  Created by wxp on 2025/2/28.
//

#import "WXPAuthKTPContentView.h"

@implementation WXPAuthKTPContentView

#pragma mark - lazy
- (UIView *)viewContent{
    if (!_viewContent) {
        _viewContent = [UIView new];
        _viewContent.backgroundColor = COLOR_WHITE;
        _viewContent.width = SCREEN_WIDTH-LEFT_MARDIN*2;
    }
    return _viewContent;
}
- (WXPAuthCameraView *)cameraView{
    if (_cameraView == nil) {
        _cameraView = [WXPAuthCameraView new];
    }
    return _cameraView;
}
- (WXPTextRemindView *)remindView{
    if (!_remindView) {
        _remindView = [WXPTextRemindView new];
        [_remindView resetViewWithContent:@"Reconocimiento exitoso de INE ayuda a aumentar la tasa de éxito de préstamo"];
        WEAKSELF
        _remindView.blockClose = ^{
            weakSelf.isHiddenRemindView = true;
            [weakSelf configUI];
            if(weakSelf.blockResetHeaderView){
                weakSelf.blockResetHeaderView();
            }
        };
    }
    return _remindView;
}
- (WXPAuthIDCardInputView *)IDCardInputView{
    if (!_IDCardInputView) {
        _IDCardInputView = [WXPAuthIDCardInputView new];
    }
    return _IDCardInputView;
}

#pragma mark - 初始化
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.isHiddenRemindView = false;
        self.widthHeight = XY(SCREEN_WIDTH, 0);
        self.backgroundColor = [UIColor clearColor];
        [self configUI];
    }
    return self;
}

- (void)configUI{
    [self.viewContent removeFromSuperview];
    self.viewContent = [UIView initWithViews:@[
        self.cameraView,
        self.isHiddenRemindView ? [UIView new] : self.remindView,
        [GlobalMethod getViewWithHeight:self.isHiddenRemindView ? CGFLOAT_MIN: LEFT_MARDIN],
        self.IDCardInputView,
    ]];
    self.viewContent.backgroundColor = [UIColor clearColor];
    [GlobalMethod setRoundView:self.viewContent color:[UIColor clearColor] numRound:16 width:0];
    self.viewContent.centerXTop = XY(self.width/2, 0);
    [self addSubview:self.viewContent];
    self.height = self.viewContent.bottom;
}

- (void)resetAuthKTPContentViewWithIsSuccess:(BOOL)isSuccess{
    self.isHiddenRemindView = isSuccess;
    [self configUI];
    if(self.blockResetHeaderView){
        self.blockResetHeaderView();
    }
}

@end
